var moveZeroes = function (nums) {
  let l = 0;
  let r = 1;
  while (r < nums.length) {
    if (nums[l] === 0) {
      if (nums[r] == 0) {
        r++;
      } else {
        let tmp = nums[l];
        nums[l] = nums[r];
        nums[l] = tmp;
        l++;
        r++;
      }
    } else {
      l++;
    }
  }
  return nums;
};

let arr = moveZeroes([0,1,0,3,12]);
console.log(arr,"arr---");